From 128bc12efd1a1105e1eb0d7586dc8bd73ed336cc Mon Sep 17 00:00:00 2001 From: robertlipe Date: Fri, 19 Jul 2013 17:01:07 +0000 Subject: [PATCH] Provide msecsTo in DateTime for Qt 4.6. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4459 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/src/core/datetime.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gpsbabel/src/core/datetime.h b/gpsbabel/src/core/datetime.h index 4cab68428..cebb55b94 100644 --- a/gpsbabel/src/core/datetime.h +++ b/gpsbabel/src/core/datetime.h @@ -104,6 +104,14 @@ public: QTime time(this->time()); return time.hour() * 10000 + time.minute() * 100 + time.second(); } + // Qt 4.6 and under doesn't have msecsTo. Fortunately, it's easy to + // provide. It's a 64-bit because if the times aren't on the same day, + // the returned value can be quite large. + int64_t msecsTo(const QDateTime& dt) { + qint64 days = this->daysTo(dt); + qint64 msecs = this->time().msecsTo(dt.time()); + return days * (1000 * 3600 * 24) + msecs; + } // Like toString, but with subsecond time that's included only when // the trailing digits aren't .000. Always UTC. @@ -116,6 +124,7 @@ public: } return this->toUTC().toString(format); } + private: time_t t_; -- 2.30.2